CC=g++
AR=ar

CFLAGS=-Wall -O2
INCLUDES = -I./include

TARGET=cv_program
OPENCV_INCLUDE = -I/usr/local/include/opencv -I/usr/local/include
OPENCV_LIBS = -L/usr/local/lib
OPENCV_LIBSDIR = -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_core
SRCS := $(wildcard *.cpp ./src/*.cpp)
LIB_SRCS := $(wildcard ./src/*.cpp)
OBJ = ./obj
OBJS := $(patsubst %cpp,$(OBJ)/%o,$(notdir $(SRCS)))
LIB_OBJS:=$(patsubst %cpp,$(OBJ)/%o,$(notdir $(LIB_SRCS)))

LIB = -lpthread
LIB_NAME = libopencv.a

all: $(TARGET) out_arm
		@echo $(LIB_OBJS)

out_arm:$(LIB_OBJS) 
	$(AR) -rcs $(LIB_NAME)  $(LIB_OBJS)


$(TARGET):$(OBJS)
	$(CC) $(INCLUDES) $(OPENCV_INCLUDE) $(CFLAGS) -o $@ $^ $(LIB) $(OPENCV_LIBS) $(OPENCV_LIBSDIR)

$(OBJ)/%.o:%.cpp
	$(CC) $(INCLUDES) $(OPENCV_INCLUDE) $(CFLAGS) -c $< -o $@ $(OPENCV_LIBS) $(OPENCV_LIBSDIR)
$(OBJ)/%.o:./src/%.cpp
	$(CC) $(INCLUDES) $(OPENCV_INCLUDE) $(CFLAGS) -c $< -o $@ $(OPENCV_LIBS) $(OPENCV_LIBSDIR)
	
clean:
	rm -r $(OBJS) $(TARGET) $(LIB_NAME)
